package com.community.process._1010.controller;


import com.community.process._1010.common.api.CommonResult;
import com.community.process._1010.dao.view.ProcessCategoryView;
import com.community.process._1010.dao.vo.ProcessFoodItemIngredientsVo;
import com.community.process._1010.domains.ProcessCategoryDTO;
import com.community.process._1010.domains.ProcessFoodItemIngredientsDTO;
import com.community.process._1010.service.ProcessFoodItemIngredientsService;
import com.oneadds.lowcode.dto.PageListData;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 到餐加工成品菜食材列表 前端控制器
 *
 * @author Zbs
 * @since 2024-09-05
 */
@RestController
@Tag(name = "到餐加工成品菜食材列表")
@RequestMapping("/process/food/item/ingredients")
@RequiredArgsConstructor
public class ProcessFoodItemIngredientsController {

    private final ProcessFoodItemIngredientsService processFoodItemIngredientsService;

    @PostMapping("/addFoodItemIngredients")
    @Operation(summary = "添加菜品食材")
    public CommonResult<String> addFoodItemIngredients(@RequestBody @Valid ProcessFoodItemIngredientsDTO.FoodItemIngredientsAdd dto) {
        this.processFoodItemIngredientsService.addFoodItemIngredients(dto);
        return CommonResult.success("");
    }

    @PostMapping("/updateFoodItemIngredients")
    @Operation(summary = "更新菜品食材")
    public CommonResult<String> updateFoodItemIngredients(@RequestBody @Valid ProcessFoodItemIngredientsDTO.FoodItemIngredientsUpdate dto) {
        this.processFoodItemIngredientsService.updateFoodItemIngredients(dto);
        return CommonResult.success("");
    }

    @PostMapping("/deleteFoodItemIngredients")
    @Operation(summary = "删除菜品食材")
    public CommonResult<String> deleteFoodItemIngredients(@RequestBody @Valid ProcessFoodItemIngredientsDTO.FoodItemIngredientsDelete dto) {
        this.processFoodItemIngredientsService.deleteFoodItemIngredients(dto);
        return CommonResult.success("");
    }

    @PostMapping("/getProcessFoodItemIngredientsVoPageList")
    @Operation(summary = "菜品获取食材列表")
    public CommonResult<PageListData<ProcessFoodItemIngredientsVo>> getProcessFoodItemIngredientsVoPageList(@RequestBody @Valid ProcessFoodItemIngredientsDTO.FoodItemIngredientsPageSearch dto) {
        PageListData<ProcessFoodItemIngredientsVo> view = this.processFoodItemIngredientsService.getProcessFoodItemIngredientsVoPageList(dto);
        return CommonResult.success(view);
    }
}

